$(function () {
    $("#page").load("/html/page.html");
});
function searchAll() {
    let data = {
        academy: $("#academy").val(),
        pageSize: $.trim($("#pageSize").val()),
        pageNum: $.trim($("#pageNum").val()),
    }
    let result = myAjax('/university/selectAll', "post", data)
    show(result.list);
    $("#pageCount").html(result.number);
}

function show(data) {
    let html = "";
    for (let i = 0; i < data.length; i++) {
        html += '   <tr> ' +
            '  <td><input type="checkbox" name="isCheck" value="'+data[i].id+'">' + data[i].id + '</td>\n' +
            '        <td>' + data[i].academy + '</td>\n' +
            '        <td>' + data[i].net + '</td>\n' +
            '        <td><input type="button" style="width: 60px;border-radius: 5px;background-color: red" value="删除" onclick="del(' + data[i].id + ')">' +
            '         <input type="button" style="width: 60px;border-radius: 5px;background-color: #5FB878" value="修改" class="edit" onclick="edit(' + data[i].id + ')"></td>' +
            '    </tr>';
    }
    $("#findAll").html(html);
}
function del(id) {
    let result = myAjax("/university/delete", "get", {id: id})
    if (result === 1) {
        alert("删除成功");
        searchAll();
    }
}
layui.use('layer');
function edit(id) {
    sessionStorage.setItem("universityId",id);
    //弹出一个页面层
        layer.open({
            type: 2,
            anim:3,
            title:'学校编辑',
            area: ['600px', '500px'],
            shadeClose: true, //点击遮罩关闭
            content: ['/html/universityEdit.html','no'],
        })
}
function add() {
    layer.open({
        type: 2,
        anim:1,
        title:'学校新增',
        area: ['600px', '500px'],
        shadeClose: true, //点击遮罩关闭
        content: ['/html/universityAdd.html','no'],
    })
}
